package diamondServer.businesslogic.resource.loader;

import diamondServer.businesslogic.resource.Resource;
import diamondServer.resources.Message;
import diamondServer.resources.MessageFake;
import diamondServer.resources.Service;
import diamondServer.resources.ServiceFake;

import junit.framework.TestCase;

/**
 * Only part of needed tests are here. Some other tests can be found in the
 * {@link LoaderManualTest} class.
 */
public class URLResourceLoaderTest
		extends TestCase
{
	private ResourceLoader loader;

	protected void setUp() throws Exception
	{
		loader = new URLResourceLoader();
	}

	protected void tearDown() throws Exception
	{
		super.tearDown();
	}

	public void testLoad() throws Exception
	{
		Resource r =
			loader.load(MessageFake.class.getName(), 
						ServiceFake.class.getName());
		
		assertTrue(r.getMessage() instanceof Message);
		assertTrue(r.getService() instanceof Service);
	}
	
	/*
	 * shouldn't throw exception
	 */
	public void testLoadTwice() throws Exception
	{
		Resource r1 = loader.load(MessageFake.class.getName(), 
				ServiceFake.class.getName());

		Resource r2 = loader.load(MessageFake.class.getName(), 
				ServiceFake.class.getName());
		
		assertFalse(r1.getMessage()==r2.getMessage());
	}

}
